package guava;

import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

/**
 * map 工具类
 * @author zhoujie
 * @date 2020-07-31
 */
@Slf4j
public class MapsTest {
    /**
     * Maps.filterValues
     */
    @Test
    public void test01() {
        Map<String, Integer> user = new HashMap<>();
        user.put("张三", 20);
        user.put("李四", 22);
        user.put("王五", 25);
        //所有年龄大于20岁的人员
        Map<String, Integer> filtedMap = Maps.filterValues(user,v->v>20);
        log.info(filtedMap.toString());
    }

    @Test
    public void test02(){
        Multimap<String, String> phone = ArrayListMultimap.create();
        phone.put("sky","110");
        phone.put("sky","120");
        phone.put("sky","119");
        Collection<String> sky = phone.get("sky");
        log.info(sky.toString());
    }
}
